C_OPTS=-O2 -I./src
SRC=./src
OUT=./out
LIB=./lib


OBJS=$(OUT)/adler32.o \
	$(OUT)/compress.o \
	$(OUT)/crc32.o \
	$(OUT)/deflate.o \
	$(OUT)/gzio.o \
	$(OUT)/infback.o \
	$(OUT)/inffast.o \
	$(OUT)/inflate.o \
	$(OUT)/inftrees.o \
	$(OUT)/minigzip.o \
	$(OUT)/trees.o \
	$(OUT)/uncompr.o \
	$(OUT)/unzip.o \
	$(OUT)/zip.o \
	$(OUT)/zutil.o


all: $(LIB)/libzlib.a


$(LIB)/libzlib.a : $(OBJS)
	ar q $(LIB)/libzlib.a $(OBJS)


$(OUT)/adler32.o:  $(SRC)/adler32.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/compress.o: $(SRC)/compress.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/crc32.o:    $(SRC)/crc32.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/deflate.o:  $(SRC)/deflate.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/gzio.o:     $(SRC)/gzio.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/infback.o:  $(SRC)/infback.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/inffast.o:  $(SRC)/inffast.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/inflate.o:  $(SRC)/inflate.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/inftrees.o: $(SRC)/inftrees.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/minigzip.o: $(SRC)/minigzip.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/trees.o:    $(SRC)/trees.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/uncompr.o:  $(SRC)/uncompr.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/unzip.o:    $(SRC)/unzip.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/zip.o:      $(SRC)/zip.c
	gcc -c $(C_OPTS) -c $< -o $@
$(OUT)/zutil.o:    $(SRC)/zutil.c
	gcc -c $(C_OPTS) -c $< -o $@


clean:
	rm $(OUT)/*.o
	rm $(LIB)/*.a


.PHONY: all clean
